package Person.ith_31;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Scanner;

public class StudentManager {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Student> array = new ArrayList<Student>();
        while(true){
        System.out.println("------欢迎来到学生管理系统------");
        System.out.println("1 添加学生");
        System.out.println("2 删除学生");
        System.out.println("3 修改学生");
        System.out.println("4 查看所有学生");
        System.out.println("5 退出");
        System.out.println("请输入你的选择： ");
        String line = sc.nextLine();
        switch(line){
            case "1":
                System.out.println("添加学生");
                break;
            case "2":
                System.out.println("删除学生");
                break;
            case "3":
                System.out.println("修改学生");
                break;
            case "4":
                System.out.println("查看所有学生");
                break;
            case "5":
                System.out.println("谢谢使用！");
                System.exit(0);
        }
        }

    }
    public static void addStudent(ArrayList<Student> array){
Scanner sc = new Scanner(System.in);
String sid;
while(true){
    System.out.println("请输入学生学号： ");
     sid = sc.nextLine();
    boolean flag = isUsed(array,sid);
    if(flag){
        System.out.println("学好已经被使用");

    }else{
        break;
    }
}

        System.out.println("请输入学生姓名： ");
        String name = sc.nextLine();
        System.out.println("请输入学生年龄： ");
        String age  = sc.nextLine();
        System.out.println("请输入学生居住地： ");
        String address = sc.nextLine();
        Student s = new Student();
        s.setAge(age);
        s.setAddress(address);
        s.setName(name);
        s.setSid(sid);
        array.add(s);
        System.out.println("添加学生成功！");
    }
 public static  boolean isUsed(ArrayList<Student> array,String sid){
       Scanner sc = new Scanner(System.in);
        boolean flag = false;
        for(int i=0;i< array.size();i++){
            Student s = array.get(i);
            if(s.getSid().equals(sid)){
                flag=true;
                break;
            }
        }
        return flag;
 }
public static void findStudent(ArrayList<Student> array){
        Scanner sc= new Scanner(System.in);
    System.out.println("请输入需要查看的学生学号： ");
    String sid = sc.nextLine();
    if(array.size()==0){
        System.out.println("无信息，请先进行添加后在进行查询！");
        return;
    }else{
        System.out.println("学号\t\t\t姓名\t\t\t年龄\t\t\t居住地");
        for(int i=0;i< array.size();i++){
            Student s = array.get(i);
            System.out.println(s.getSid()+"\t"+s.getName()+"\t"+s.getAge()+"\t"+s.getAddress());
        }
        }


}
public static void deleteStudent(ArrayList<Student> array){
        Scanner sc = new Scanner(System.in);
    System.out.println("请输入需要删除的学生学号： ");
    String sid = sc.nextLine();

}









}
